{extend name="template/base" /}
{block name="nav"}{/block}
{block name="content"}
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" action="{:url('admin/GasStation/addGasStationInfo')}">
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>商家头像：</label>
            <div id="header" class="formControls col-xs-6 col-sm-6">
                <img id="icon" src="{$vo.pic  ?? 'http://download.bihuapp.com/20190109204852.png'}" style="width: 50px; height: 50px;" alt="">
                <input id="pic" type="hidden" name="pic" value="{$vo.pic ?? 'http://download.bihuapp.com/20190109204852.png'}">
            </div>
            <div class="image-up" id="uploadImg">
                点击上传
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>商家名称：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="{$vo.station_name ?? ''}" placeholder="" name="station_name" datatype="*" nullmsg="请填写姓名">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">手机：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="{$vo.phone ?? ''}" placeholder="" name="phone" datatype="*" errormsg="手机格式错误">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"></label>
            <div id="container" style="width: 50%; height: 300px;">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">经度：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" id="lon" class="input-text" value="{$vo.lon ?? ''}" placeholder="" name="lon" datatype="*">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">纬度：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" id="lat" class="input-text" value="{$vo.lat ?? ''}" placeholder="" name="lat" datatype="*">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">地址：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="{$vo.address ?? ''}" placeholder="" name="address" datatype="*" nullmsg="请填写地址">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">92#价格：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="{$vo.price_92 ?? ''}" placeholder="" name="price_92" datatype="*" nullmsg="请填写地址">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">95#价格：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="{$vo.price_95 ?? ''}" placeholder="" name="price_95" datatype="*" nullmsg="请填写地址">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">简介：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <textarea name="intro" id="" cols="105" rows="10">{$vo.intro ?? ''}</textarea>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-primary radius">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script>
    $(function () {
        $("[name='status'][value='{$vo.status ?? '1'}']").attr("checked",true);

        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form").Validform({
            tiptype:2,
            ajaxPost:true,
            showAllError:true,
            callback:function(ret){
                ajax_progress(ret);
            }
        });
    })
</script>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.13&key=ac7ce3c200e49a57980cc71f32c7c0b8"></script>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.13&key=ac7ce3c200e49a57980cc71f32c7c0b8&plugin=AMap.Geocoder"></script>
<script>
    var map = new AMap.Map('container');
    window.onLoad  = function(){
        var map = new AMap.Map('container', {
            resizeEnable: true, //是否监控地图容器尺寸变化
            zoom:11, //初始化地图层级
            center: [118.016974,37.383542] //初始化地图中心点
        });
    }

    $("#container").click(function (e) {
        var offset = $(this).offset();
        var relativeX = (e.pageX - offset.left);
        var relativeY = (e.pageY - offset.top);

        var pixel = new AMap.Pixel(relativeX, relativeY);
        var lnglat = map.containerToLngLat(pixel);

        $("#lon").val(lnglat.lng);
        $("#lat").val(lnglat.lat);
    });
</script>
<script>
    var uploader = WebUploader.create({
        //自动上传
        auto: true,
        //swf文件路径
        swf: '__LIB__/webuploader/Uploader.swf',
        ////文件接收服务端
        server: "/admin/Common/uploadImg",
        //选择文件的按钮。
        pick: "#uploadImg",
        //单次上传最多图片数
        fileNumLimit: 100,
        fileVal: "pic",
        duplicate: true,
        //允许选择的图片格式
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/*'
        }
    });

    uploader.on('uploadSuccess', function (file, response) {
        console.log(response);
        if(response['url']) {
            $('#icon').attr('src',response['url']);
            $("#pic").val(response['url']);
        } else {
            ajaxReturn(response);
        }
    });
</script>
{/block}